#include<stdio.h>
#include<iostream>
using namespace std;
bool f(int y);
int main(){
	int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int y,m,d,day;
	cin>>y>>m>>d>>day;
	m--;
	while(day--){
		d++;
		if(f(y)){
			if(d>a[m]){
				d-=a[m];
				m++;
			}
		}
		else{
			if(d>b[m]){
				d-=b[m];
				m++;
			}
		}
		if(m>=12){
			m-=12;
			y++;
		}
	}
	printf("%04d-%02d-%02d",y,m+1,d);
	return 0;
}
bool f(int y){
	if(y%400==0)
		return true;
	if(y%4==0&&y%100)
		return true;
	return false;
}